package com.park.web.controller.pub;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.park.client.model.exam.ExamPaperQuestionModel;
import com.park.client.model.exam.ExamPaperTypeDetailModel;
import com.park.client.service.exam.ExamPaperService;
import com.park.client.service.exam.ExamPaperTypeDetailService;
import com.park.client.vo.ExamPaperVo;
import com.park.common.util.Page;
import com.park.web.contant.Global;
import com.park.web.controller.BaseController;

@Controller
@RequestMapping("/public/exam")
public class PublicExamController extends BaseController{

	@Autowired
	private ExamPaperService examPaperService;
	
	@Autowired
	private ExamPaperTypeDetailService examPaperTypeDetailService;
	
	/**
	 * 试卷类别明细
	 */
	@RequestMapping("examPaperTypeDetail/{examPaperTypeId}")
	public String examPaperTypeDetail(@PathVariable("examPaperTypeId")Long examPaperTypeId,@RequestParam(name="pageNow",defaultValue="1")Integer pageNow,HttpServletRequest request){
		ExamPaperTypeDetailModel paperModel = new ExamPaperTypeDetailModel();
		paperModel.setExamSubjectId(examPaperTypeId);
		Integer total = examPaperTypeDetailService.selectTotal(paperModel);
		Page page = new Page(pageNow,total,10);
		paperModel.setStartPos(page.getStartPos());
		paperModel.setPageSize(page.getPageSize());
		List<ExamPaperTypeDetailModel> examPaperTypeDetailModels = examPaperTypeDetailService.selectPagination(paperModel);
		request.setAttribute("examPaperTypeDetailModels", examPaperTypeDetailModels);
		request.setAttribute("page", page);
		return Global.PUBLIC_PATH+"exam/examPaperTypeDetail";
	}
	
	/**
	 * 试卷问题列表
	 */
	@RequestMapping("examPaperQnsDetail/{detailId}")
	public String examPaperQnsDetail(@PathVariable("detailId")Long detailId,@RequestParam(name="pageNow",defaultValue="1")Integer pageNow,HttpServletRequest request){
		ExamPaperVo examPaperVo = new ExamPaperVo();
		examPaperVo.setExamPaperTypeDetailId(detailId);
		Integer total = examPaperService.selectTotal(examPaperVo);
		Page page = new Page(pageNow,total,20);
		examPaperVo.setStartPos(page.getStartPos());
		examPaperVo.setPageSize(page.getPageSize());
		List<ExamPaperVo> examPaperQnsVos = examPaperService.selectPagination(examPaperVo);
		request.setAttribute("examPaperQnsVos", examPaperQnsVos);
		request.setAttribute("page", page);
		return Global.PUBLIC_PATH+"exam/examPaperQnsDetail";
	}
	
	/**
	 *试卷题目 
	 */
	@RequestMapping("paperQnsList/{examSubjectId}")
	private List<ExamPaperQuestionModel> paperQnsList(){
		return null;
	};
}
